# Definition for a binary tree node.
import collections
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution:
    def binaryTreePaths(self, root):
        """
        :type root: TreeNode
        :rtype: List[str]
        """
        if not root:
            return []
        a = []
        deque = collections.deque()
        m = ''
        deque.append((root,m))
        while deque:
            node,q = deque.popleft()
            if node:
                if not node.left and not node.right:
                    a.append(q + str(node.val))
                deque.append((node.left,q + str(node.val)+'->'))
                deque.append((node.right ,q + str(node.val) + '->'))
        print(a)

        # res = []
        # if not root:
        #     return res
        # if not root.left and not root.right:
        #     res.append(str(root.val))
        #     return res
        # for path in self.binaryTreePaths(root.left):
        #     res.append(str(root.val) + '->' + path)
        # for path in self.binaryTreePaths(root.right):
        #     res.append(str(root.val) + '->' + path)
        # return res








m1 = TreeNode(1)
m1.left = TreeNode(2)
m1.right = TreeNode(3)
m1.left.right =  TreeNode(5)
m1.left.left = TreeNode(6)
m1.right.right = TreeNode(2)
s = Solution()

t = s.binaryTreePaths(m1)
print(t)
